package com.chuangke.system.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.chuangke.common.http.HttpResult;
import com.chuangke.system.entity.SysConfigType;
import com.chuangke.system.service.SysConfigTypeService;

@RestController
@RequestMapping("configtype")
public class SysConfigTypeController {

	@Autowired
	private SysConfigTypeService sysConfigTypeService;

	@PreAuthorize("hasAuthority('login:action')")
	@PostMapping(value = "/save")
	public HttpResult save(@RequestBody SysConfigType sysConfigType) {
		sysConfigTypeService.save(sysConfigType);
		return HttpResult.ok();
	}

	@PreAuthorize("hasAuthority('login:action')")
	@PostMapping(value = "/delete")
	public HttpResult shiftDelete(@RequestBody SysConfigType sysConfigType) {
		sysConfigTypeService.delete(sysConfigType.getId());
		return HttpResult.ok();
	}

	@PreAuthorize("hasAuthority('login:action')")
	@PostMapping(value = "/update")
	public HttpResult update(@RequestBody SysConfigType sysConfigType) {
		sysConfigTypeService.update(sysConfigType);
		return HttpResult.ok();
	}

	@PreAuthorize("hasAuthority('login:action')")
	@GetMapping(value = "/list")
	public HttpResult list() {
		return HttpResult.ok(sysConfigTypeService.findAll().values());
	}

}
